using Avalonia.Styling;
using DesktopApp.ViewModels; // For RuleItemViewModel
using System.Threading.Tasks;
using Avalonia.Platform.Storage; // Add this for file dialogs
using System.Collections.Generic; // Add this for List<>

namespace DesktopApp.ViewModels.Services
{
    /// <summary>
    /// Defines the contract for UI-related interactions like showing dialogs and managing themes.
    /// </summary>
    public interface IUIService
    {
        /// <summary>
        /// Shows the 'About' window.
        /// </summary>
        Task ShowAboutDialogAsync();

        /// <summary>
        /// Shows the rule editor window to add or edit a rule.
        /// </summary>
        /// <param name="existingRuleViewModel">The ViewModel pre-populated with existing rule data for editing, or a new ViewModel for adding.</param>
        /// <returns>A RuleItemViewModel representing the added/edited rule data, or null if cancelled.</returns>
        Task<RuleItemViewModel?> ShowRuleEditorDialogAsync(RuleEditorViewModel existingRuleViewModel);

        /// <summary>
        /// Shows a confirmation dialog.
        /// </summary>
        /// <param name="title">The dialog title.</param>
        /// <param name="message">The confirmation message.</param>
        /// <returns>True if the user confirmed, false otherwise.</returns>
        Task<bool> ShowConfirmationDialogAsync(string title, string message);

        /// <summary>
        /// Shows a dialog prompting the user for text input.
        /// </summary>
        /// <param name="title">The dialog title.</param>
        /// <param name="label">The message/label displayed above the input field.</param>
        /// <param name="defaultValue">The default value in the input field.</param>
        /// <returns>The text entered by the user, or null if cancelled.</returns>
        Task<string?> ShowInputDialogAsync(string title, string label, string defaultValue = "");

        /// <summary>
        /// Applies the specified theme variant to the application.
        /// </summary>
        /// <param name="themeVariant">The theme variant to apply.</param>
        void ApplyTheme(ThemeVariant themeVariant);

        /// <summary>
        /// Opens the specified URL in the default web browser.
        /// </summary>
        /// <param name="url">The URL to open.</param>
        /// <returns>True if the URL was opened successfully, false otherwise.</returns>
        Task<bool> OpenUrlAsync(string url);

        /// <summary>
        /// Shows the open file dialog to select a single file.
        /// </summary>
        /// <param name="title">The dialog title.</param>
        /// <param name="filters">A list of file type filters.</param>
        /// <returns>An IStorageFile representing the selected file, or null if cancelled.</returns>
        Task<IStorageFile?> ShowOpenFileDialogAsync(string title, List<FilePickerFileType>? filters = null);

        /// <summary>
        /// Shows the save file dialog.
        /// </summary>
        /// <param name="title">The dialog title.</param>
        /// <param name="defaultExtension">The default file extension (e.g., \"json\").</param>
        /// <param name="suggestedFileName">The suggested file name.</param>
        /// <param name="filters">A list of file type filters.</param>
        /// <returns>An IStorageFile representing the selected save location, or null if cancelled.</returns>
        Task<IStorageFile?> ShowSaveFileDialogAsync(string title, string? defaultExtension = null, string? suggestedFileName = null, List<FilePickerFileType>? filters = null);
    }
} 